home *** CD-ROM | disk | FTP | other *** search
/ Australian Personal Computer 2004 July / APC0407D2.iso / workshop / onlineco / files / ImageMagick-6.0.1-Q16-windows-dll.exe / {app} / PerlMagick / demo / shapes.pl < prev    next >
Encoding:
Perl Script  |  2003-12-29  |  1.2 KB  |  40 lines

  1. #!/usr/bin/perl
  2. # GD example using PerlMagick methods.
  3.  
  4. use Image::Magick;
  5.  
  6. #
  7. # Create a 300x300 white canvas.
  8. #
  9. $image=Image::Magick->new;
  10. $image->Set(size=>'300x300');
  11. $image->Read('xc:white');
  12. #
  13. # Draw shapes.
  14. #
  15. $tile=Image::Magick->new;
  16. $tile->Read('tile.gif');
  17. $image->Draw(primitive=>'Polygon',tile=>$tile,fill=>'none',
  18.   points=>'30,30 100,10 190,290 30,290');
  19. $image->Draw(stroke=>'red',primitive=>'Ellipse',stroke=>'black',fill=>'red',
  20.   strokewidth=>5,points=>'100,100 50,75 0,360');
  21. $image->Draw(primitive=>'Polygon',fill=>'none',stroke=>'black',strokewidth=>5,
  22.   points=>'30,30 100,10 190,290 30,290');
  23. $image->ColorFloodfill(geometry=>'+132+62',fill=>'blue',bordercolor=>'black');
  24. #
  25. # Draw text.
  26. #
  27. $image->Annotate(fill=>'red',geometry=>'+150+20',font=>'Generic.ttf',
  28.   pointsize=>18,text=>'Hello world!');
  29. $image->Annotate(fill=>'blue',geometry=>'+150+38',font=>'Generic.ttf',
  30.   pointsize=>14,text=>'Goodbye cruel world!');
  31. $image->Annotate(fill=>'black',geometry=>'+280+120',font=>'Generic.ttf',
  32.   pointsize=>14,text=>"I'm climbing the wall!",rotate=>90.0);
  33. #
  34. # Write image.
  35. #
  36. print "Write image...\n";
  37. $image->Write('shapes.gif');
  38. print "Display image...\n";
  39. $image->Write('win:');
  40.